#include<stdio.h>
#include<string.h>
int main(){
    FILE* fp = fopen("1.txt","w+");
    if(fp == NULL){
        perror("fopen");
        return 0;
    }
    //printf("%d\n",fp->_fileno);
    //测试写
    const char* ptr = "hello world";
     printf("sucess\n");
    size_t wsize= fwrite(ptr,1,strlen(ptr),fp);
    printf("%ld\n",wsize);
     //测试读
     fseek(fp, 3, SEEK_SET);
     char buf[1024] = {0};
     size_t r_size = fread(buf, 1, sizeof(buf) - 1, fp);
     printf("r_size = %ld\n", r_size);
     printf("buf = %s\n", buf);
     //如果不关闭文件流指针，则会造成文件句柄泄露
    fclose(fp);
    return 0;
}

